using B.S.XZYData.Api.Read.Application.Command.AssemblyWorkOrder;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace B.S.XZYData.Api.Read.Controllers
{
    /// <summary>
    /// 装配工单管理控制器
    /// </summary>
    [ApiController]
    [Route("api/[controller]")]
    public class AssemblyWorkOrderController : ControllerBase
    {
        private readonly IMediator _mediator;

        public AssemblyWorkOrderController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 装配工单分页查询
        /// </summary>
        /// <param name="command">查询命令</param>
        /// <returns>分页结果</returns>
        [HttpPost("query")]
        public async Task<IActionResult> QueryAssemblyWorkOrder([FromBody] QueryAssemblyWorkOrderCommand command)
        {
            var result = await _mediator.Send(command);
            return Ok(result);
        }

        /// <summary>
        /// 根据装配工单Id查询对应的装配工单产品明细信息
        /// </summary>
        /// <param name="assemblyWorkOrderId">装配工单ID</param>
        /// <returns>产品明细列表</returns>
        [HttpGet("product-detail/{assemblyWorkOrderId}")]
        public async Task<IActionResult> GetAssemblyWorkOrderProductDetail(long assemblyWorkOrderId)
        {
            var command = new QueryAssemblyWorkOrderProductDetailCommand
            {
                AssemblyWorkOrderId = assemblyWorkOrderId
            };
            var result = await _mediator.Send(command);
            return Ok(result);
        }
    }
} 